<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr" lang="en"><head>



<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
			<script type="text/javascript" src="../../../../main/lib/jquery-1.3.1.js"></script>
<script type="text/javascript">

function loadJSON(fname) 
{

	$(window).bind("ajaxError", function() {
	  $("#zone").append(" <p>Ajax query for fixture failed</p><br/>");
	}); 

	$.getJSON(fname,
        function(response){
				printMove(response);
        });		
}

function printMove(entry){
			
			if(entry.actingPlayer == null){
				$("#zone").append("Active Player=[empty]<br/>");
			}else{
				$("#zone").append("ActivePlayer=[" +  entry.actingPlayer + "]<br/>");
			}
			
			if(entry.activity == null){
				$("#zone").append("activity=[empty](cannot be null)<br/>");
			}else{
				$("#zone").append("activity=[" +  entry.activity + "]<br/>");
			}

			if(entry.preMove == null){
				$("#zone").append("preMove=[empty]<br/>");
			}else{
				$("#zone").append("preMove=[" +  entry.preMove + "]<br/>");
			}

			if(entry.tiles == null){
				$("#zone").append("tiles=[empty]<br/>");
			}else{

				for(tile in entry.tiles) {
					$("#zone").append("Move=[" + tile + "]:<br />");
					
					if(entry.tiles[tile].coOrds == null){
						$("#zone").append("&nbsp; ref=[empty] (cannot be null)<br/>");
					}else{
						$("#zone").append("&nbsp; ref=[" +  entry.tiles[tile].coOrds + "]<br/>");
					}

					if(entry.tiles[tile].coOrds == null){
						$("#zone").append("&nbsp; bg=[empty] (cannot be null)<br/>");
					}else{
						$("#zone").append("&nbsp; bg=[" +  entry.tiles[tile].bg + "]<br/>");
					}

					if(entry.tiles[tile].unit == null){
						$("#zone").append("&nbsp; unit=[empty]<br/>");
					}else{
						$("#zone").append("&nbsp; unit=[" +  entry.tiles[tile].unit + "]<br/>");
					}

					if(entry.tiles[tile].occupant == null){
						$("#zone").append("&nbsp; player=[empty]<br/>");
					}else{
						$("#zone").append("&nbsp; player=[" +  entry.tiles[tile].occupant + "]<br/>");
					}
				}
			}
			
			if(entry.postMove == null){
				$("#zone").append("postMove=[empty]<br/>");
			}else{
				$("#zone").append("postMove=[" +  entry.postMove + "]<br/>");
			}			
}


</script>
	<title>Ajax Get JSON Demo - Using Jquery</title></head>
<body bgcolor="#ffffff">
<h1>Ajax Get Move JSON</h1>
<hr>
<form name="ajax" method="post" action="">
			
  <p>
    <input value=" Click to load the JSON menu file " onclick="loadJSON('../test/fixture/move1.json')" type="button">
  </p>

</form>
	
<div id="zone"></div>

<p><br>
  <a href="../test/fixture/1/move1.json">View the JSON file</a> </p>
<br>
</body></html>

